#pragma once
#include "GameCore.h"
#include "addons\SpriteCounter.h"
#include <action\Action.h>

// ---------------------------------------------------
//
// ---------------------------------------------------
class LevelInfoAction : public ds::Action {

public:
	LevelInfoAction(AstroGame* engine) : ds::Action("LevelInfo") , m_Core(engine) , m_LevelInfo(m_Core->levelInfo()) {
		m_LevelInfo->setActive(false);
	}
	virtual ~LevelInfoAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	float m_LevelTimer;
	AstroGame* m_Core;
	ds::SpriteCounter* m_LevelInfo;
};

// ---------------------------------------------------
// Powerup Info
// ---------------------------------------------------
class PowerupInfoAction : public ds::Action {

public:
	PowerupInfoAction(AstroGame* engine,const char* name,ds::SpriteNode* sprites,const ds::Rect& textureRect) 
		: ds::Action(name) , m_Core(engine) , m_TextureRect(textureRect) , m_Sprites(sprites) {
		m_SpriteHandle = sprites->add(ds::Vec2(0,0),m_TextureRect);
		m_StartX = (1024 - textureRect.width())/2;
		m_StartY = (768 - textureRect.height())/2;
		sprites->setVisible(m_SpriteHandle,false);
	}
	virtual ~PowerupInfoAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	ds::Rect m_TextureRect;
	ds::SHandle m_SpriteHandle;
	float m_InfoTimer;
	AstroGame* m_Core;
	ds::SpriteNode* m_Sprites;
	int m_StartX;
	int m_StartY;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class ClearAction : public ds::Action {

public:
	ClearAction(AstroGame* engine) : ds::Action("ClearActors") , m_Core(engine) {}
	virtual ~ClearAction() {}
	void start();
	void stop() {}
	void update(float elapsed) {}
private:
	AstroGame* m_Core;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class ShootAction : public ds::Action {

public:
	ShootAction(AstroGame* engine) : ds::Action("Shoot") , m_Core(engine) {}
	virtual ~ShootAction() {}
	void start();
	void stop() {}
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_Timer;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class SetTargetsAction : public ds::Action {

public:
	SetTargetsAction(AstroGame* engine) : ds::Action("SetTargets") , m_Core(engine) , m_PickupCounter(0) {}
	virtual ~SetTargetsAction() {}
	void start() {
		m_PickupCounter = 0;
	}
	void stop() {}
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_Timer;
	int m_PickupCounter;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class UpdateEnemiesAction : public ds::Action {

public:
	UpdateEnemiesAction(AstroGame* engine) : ds::Action("UpdateEnemies") , m_Core(engine) {}
	virtual ~UpdateEnemiesAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	AstroGame* m_Core;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class SwimmerAction : public ds::Action {

public:
	SwimmerAction(AstroGame* engine) : ds::Action("Swimmer") , m_Core(engine) , m_Count(3) , m_Spawning(5.0f) {}
	virtual ~SwimmerAction() {}
	void start();
	void stop();
	void update(float elapsed);
	void setCount(int count) {
		m_Count = count;
	}
	void setSpawning(float spawning) {
		m_Spawning = spawning;
	}
private:
	AstroGame* m_Core;
	float m_SpawnTimer;
	float m_Spawning;
	int m_Count;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class BlitzAction : public ds::Action {

public:
	BlitzAction(AstroGame* engine) : ds::Action("Blitz") , m_Core(engine) , m_FadeTimer(0.0f) {
		m_ShaderHandle = gEngine->getResourceManager().findByName("Circle",ds::RS_SHADER);
	}
	virtual ~BlitzAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_FadeTimer;
	ds::ResourceHandle m_ShaderHandle;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class FlashAction : public ds::Action {

public:
	FlashAction(AstroGame* engine) : ds::Action("Flash") , m_Core(engine) , m_Timer(0.0f) {
		m_ShaderHandle = gEngine->getResourceManager().findByName("Circle",ds::RS_SHADER);
	}
	virtual ~FlashAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_Timer;
	ds::ResourceHandle m_ShaderHandle;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class GrayFadeAction : public ds::Action {

public:
	GrayFadeAction(AstroGame* engine) : ds::Action("GrayFade") , m_Core(engine) , m_FadeTimer(0.0f) {
		m_ShaderHandle = gEngine->getResourceManager().findByName("PP",ds::RS_SHADER);
	}
	virtual ~GrayFadeAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_FadeTimer;
	ds::ResourceHandle m_ShaderHandle;
};

// ---------------------------------------------------
//
// ---------------------------------------------------
class BackgroundAction : public ds::Action {

public:
	BackgroundAction(AstroGame* engine) : ds::Action("Background") , m_Core(engine) , m_Timer(0.0f) {
		m_ShaderHandle = gEngine->getResourceManager().findByName("BGShader",ds::RS_SHADER);
	}
	virtual ~BackgroundAction() {}
	void start();
	void stop();
	void update(float elapsed);
private:
	AstroGame* m_Core;
	float m_Timer;
	ds::ResourceHandle m_ShaderHandle;
};